local fenwei = fk.CreateSkill{
  name = "lingling__fenwei",
}

Fk:loadTranslationTable{
  ["lingling__fenwei"] = "奋危",
  [":lingling__fenwei"] = "当一名其他角色不因此法回复体力后，你可以弃置两张牌，令其回复或失去1点体力。每以此法弃置一张【杀】，你便摸一张牌。",

  ["#lingling__fenwei-invoke"] = "奋危：你可以弃置两张牌，令 %dest 回复或失去1点体力",
}

fenwei:addEffect(fk.HpRecover, {
  anim_type = "support",
  can_trigger = function(self, event, target, player, data)
    return target ~= player and player:hasSkill(fenwei.name) and
      #player:getCardIds("he") > 1 and not target.dead and
      data.skillName ~= fenwei.name
  end,
  on_cost = function (self, event, target, player, data)
    local room = player.room
    local success, dat = room:askToUseActiveSkill(player, {
      skill_name = "#lingling__fenwei_active",
      prompt = "#lingling__fenwei-invoke::"..target.id,
      extra_data = {
        to = target.id,
      },
    })
    if success and dat then
      event:setCostData(self, {tos = {target}, cards = dat.cards, choice = dat.interaction})
      return true
    end
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    local choice = event:getCostData(self).choice
    local cards = event:getCostData(self).cards
    local n = #table.filter(cards, function (id)
      return Fk:getCardById(id).trueName == "slash"
    end)
    room:throwCard(cards, fenwei.name, player, player)
    if not target.dead then
      if choice == "recover" then
        room:recover{
          who = target,
          num = 1,
          recoverBy = player,
          skillName = fenwei.name,
        }
      else
        room:loseHp(target, 1, fenwei.name)
      end
    end
    if not player.dead and n > 0 then
      player:drawCards(n, fenwei.name)
    end
  end,
})

return fenwei
